package org.patterns.behavior.command;


public class Client {
    public static void main(String[] args) {
        SettingWindow window = new SettingWindow("功能键设置");

        FunctionButton btnA = new FunctionButton("功能键A");
        FunctionButton btnB = new FunctionButton("功能键B");

        //通过读取配置文件和反射生成具体命令对象
        Command command1 = (Command) XMLUtil.getBean(0);
        Command command2 = (Command) XMLUtil.getBean(1);

        //将命令对象注入功能键
        btnA.setCommand(command1);
        btnB.setCommand(command2);

        window.addFunctionButton(btnA);
        window.addFunctionButton(btnB);
        window.display();

        //调用功能键的业务方法
        btnA.onClick();
        btnB.onClick();
    }
}